﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace mEdit.Controls
{
    public partial class TimeSpanCC : MaskedTextBox
    {
        private TimeSpan timespanValue = TimeSpan.Zero;

        public TimeSpanCC()
        {
            InitializeComponent();

            this.Mask = "00:00:00";
            this.TextAlign = HorizontalAlignment.Right;
            this.TextChanged += new EventHandler(TimeSpanCC_TextChanged);
            this.Text = timespanValue.ToString();
            
        }

        private void TimeSpanCC_TextChanged(object sender, EventArgs e)
        {
            
        }

        protected override void OnValidating(CancelEventArgs e)
        {
            TimeSpan t;
            bool conversionOk = TimeSpan.TryParse(this.Text, out t);
            if (!conversionOk)
                this.Text = timespanValue.ToString();
            else
                this.timespanValue = t;
        }
    }
}
